home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / PL 2.0 SupplementDoc Folder.sit / PL 2.0 SupplementDoc Folder / Documentation / Chapter 25. Misc. Features < prev    next >
Lisp/Scheme  |  1995-03-28  |  65KB  |  1,364 lines

  1. Common Lisp the Language, 2nd Edition
  2. -------------------------------------------------------------------------------
  3.  
  4. 25. Miscellaneous Features
  5.  
  6. In this chapter are described various things that don't seem to fit neatly
  7. anywhere else in this book: the compiler, the documentation function, debugging
  8. aids, environment inquiries (including facilities for calculating and measuring
  9. time), and the identity function.
  10.  
  11. -------------------------------------------------------------------------------
  12.  
  13.    *  The Compiler
  14.         o  Compiler Diagnostics
  15.         o  Compiled Functions
  16.         o  Compilation Environment
  17.         o  Similarity of Constants
  18.    *  Documentation
  19.    *  Debugging Tools
  20.    *  Environment Inquiries
  21.         o  Time Functions
  22.         o  Other Environment Inquiries
  23.    *  Identity Function
  24.  
  25. -------------------------------------------------------------------------------
  26.  
  27. 25.1. The Compiler
  28.  
  29. [old_change_begin]
  30. The compiler is a program that may make code run faster by translating programs
  31. into an implementation-dependent form that can be executed more efficiently by
  32. the computer. Most of the time you can write programs without worrying about
  33. the compiler; compiling a file of code should produce an equivalent but more
  34. efficient program. When doing more esoteric things, you may need to think
  35. carefully about what happens at ``compile time'' and what happens at ``load
  36. time.'' Then the difference between the syntaxes #. and #, becomes important,
  37. and the eval-when construct becomes particularly useful.
  38. [old_change_end]
  39.  
  40. [change_begin]
  41. X3J13 voted in January 1989 (SHARP-COMMA-CONFUSION)   to remove #, from the
  42. language.
  43. [change_end]
  44.  
  45. Most declarations are not used by the Common Lisp interpreter; they may be used
  46. to give advice to the compiler. The compiler may attempt to check your advice
  47. and warn you if it is inconsistent.
  48.  
  49. Unlike most other Lisp dialects, Common Lisp recognizes special declarations in
  50. interpreted code as well as compiled code. This potential source of
  51. incompatibility between interpreted and compiled code is thereby eliminated in
  52. Common Lisp.
  53.  
  54. The internal workings of a compiler will of course be highly
  55. implementation-dependent. The following functions provide a standard interface
  56. to the compiler, however.
  57.  
  58. [old_change_begin]
  59.  
  60. [Function]
  61. compile name &optional definition
  62.  
  63. If definition is supplied, it should be a lambda-expression, the interpreted
  64. function to be compiled. If it is not supplied, then name should be a symbol
  65. with a definition that is a lambda-expression; that definition is compiled and
  66. the resulting compiled code is put back into the symbol as its function
  67. definition.
  68. [old_change_end]
  69.  
  70. [change_begin]
  71. X3J13 voted in October 1988 (COMPILE-ARGUMENT-PROBLEMS)   to restate the
  72. preceding paragraph more precisely and to extend the capabilities of compile.
  73. If the optional definition argument is supplied, it may be either a
  74. lambda-expression (which is coerced to a function) or a function to be
  75. compiled; if no definition is supplied, the symbol-function of the symbol is
  76. extracted and compiled. It is permissible for the symbol to have a macro
  77. definition rather than a function definition; both macros and functions may be
  78. compiled.
  79.  
  80. It is an error if the function to be compiled was defined interpretively in a
  81. non-null lexical environment. (An implementation is free to extend the behavior
  82. of compile to compile such functions properly, but portable programs may not
  83. depend on this capability.) The consequences of calling compile on a function
  84. that is already compiled are unspecified.
  85. [change_end]
  86.  
  87. [old_change_begin]
  88. The definition is compiled and a compiled-function object produced. If name is
  89. a non-nil symbol, then the compiled-function object is installed as the global
  90. function definition of the symbol and the symbol is returned. If name is nil,
  91. then the compiled-function object itself is returned. For example:
  92.  
  93. (defun foo ...) => foo        ッA function definition
  94. (compile 'foo) => foo           ;Compile it
  95. ;Now foo runs faster (maybe)
  96.  
  97. (compile nil
  98.          '(lambda (a b c) (- (* b b) (* 4 a c))))
  99.    => a compiled function of three arguments that computes
  100.  
  101. [old_change_end]
  102.  
  103. [change_begin]
  104. X3J13 voted in June 1989 (COMPILER-DIAGNOSTICS)   to specify that compile
  105. returns two additional values indicating whether the compiler issued any
  106. diagnostics (see section 25.1.1).
  107.  
  108. X3J13 voted in March 1989 (FUNCTION-NAME)   to extend compile to accept as a
  109. name any function-name (a symbol or a list whose car is setf-see section 7.1).
  110. One may write (compile '(setf cadr)) to compile the setf expansion function for
  111. cadr.
  112. [change_end]
  113.  
  114. [old_change_begin]
  115.  
  116. [Function]
  117. compile-file input-pathname &key :output-file
  118.  
  119. The input-pathname must be a valid file specifier, such as a pathname. The
  120. defaults for input-filename are taken from the variable
  121. *default-pathname-defaults*. The file should be a Lisp source file; its
  122. contents are compiled and written as a binary object file.
  123. [old_change_end]
  124.  
  125. [change_begin]
  126. X3J13 voted in March 1989 (COMPILER-VERBOSITY)   to add two new keyword
  127. arguments :verbose and :print to compile-file by analogy with load. The new
  128. function definition is as follows.
  129.  
  130. [Function]
  131. compile-file input-pathname &key :output-file :verbose :print
  132.  
  133. The :verbose argument (which defaults to the value of *compile-verbose*), if
  134. true, permits compile-file to print a message in the form of a comment to
  135. *standard-output* indicating what file is being compiled and other useful
  136. information.
  137.  
  138. The :print argument (which defaults to the value of *compile-print*), if true,
  139. causes information about top-level forms in the file being compiled to be
  140. printed to *standard-output*. Exactly what is printed is
  141. implementation-dependent; nevertheless something will be printed.
  142.  
  143. X3J13 voted in March 1988 (PATHNAME-STREAM)   to specify exactly which streams
  144. may be used as pathnames (see section 23.1.6).
  145.  
  146. X3J13 voted in June 1989 (PATHNAME-WILD)   to clarify that supplying a wild
  147. pathname as the input-pathname argument to compile-file has
  148. implementation-dependent consequences; compile-file might signal an error, for
  149. example, or might compile all files that match the wild pathname.
  150.  
  151. X3J13 voted in June 1989 (PATHNAME-LOGICAL)   to require compile-file to accept
  152. logical pathnames (see section 23.1.5).
  153. [change_end]
  154.  
  155. The :output-file argument may be used to specify an output pathname; it
  156. defaults in a manner appropriate to the implementation's file system
  157. conventions.
  158.  
  159. [change_begin]
  160. X3J13 voted in June 1989 (COMPILER-DIAGNOSTICS)   to specify that compile-file
  161. returns three values: the truename of the output file (or nil if the file could
  162. not be created) and two values indicating whether the compiler issued any
  163. diagnostics (see section 25.1.1).
  164.  
  165. X3J13 voted in October 1988 (COMPILE-FILE-PACKAGE)   to specify that
  166. compile-file, like load, rebinds *package* to its current value. If some form
  167. in the file changes the value of *package*, the old value will be restored when
  168. compilation is completed.
  169.  
  170. X3J13 voted in June 1989 (COMPILE-FILE-SYMBOL-HANDLING)   to specify
  171. restrictions on conforming programs to ensure consistent handling of symbols
  172. and packages.
  173.  
  174. In order to guarantee that compiled files can be loaded correctly, the user
  175. must ensure that the packages referenced in the file are defined consistently
  176. at compile and load time. Conforming Common Lisp programs must satisfy the
  177. following requirements.
  178.  
  179.    *  The value of *package* when a top-level form in the file is processed by
  180.      compile-file must be the same as the value of *package* when the code
  181.      corresponding to that top-level form in the compiled file is executed by
  182.      the loader. In particular, any top-level form in a file that alters the
  183.      value of *package* must change it to a package of the same name at both
  184.      compile and load time; moreover, if the first non-atomic top-level form in
  185.      the file is not a call to in-package, then the value of *package* at the
  186.      time load is called must be a package with the same name as the package
  187.      that was the value of *package* at the time compile-file was called.
  188.  
  189.    *  For every symbol appearing lexically within a top-level form that was
  190.      accessible in the package that was the value of *package* during
  191.      processing of that top-level form at compile time, but whose home package
  192.      was another package, at load time there must be a symbol with the same
  193.      name that is accessible in both the load-time *package* and in the package
  194.      with the same name as the compile-time home package.
  195.  
  196.    *  For every symbol in the compiled file that was an external symbol in its
  197.      home package at compile time, there must be a symbol with the same name
  198.      that is an external symbol in the package with the same name at load time.
  199.  
  200. If any of these conditions do not hold, the package in which load looks for the
  201. affected symbols is unspecified. Implementations are permitted to signal an
  202. error or otherwise define this behavior.
  203.  
  204. These requirements are merely an explicit statement of the status quo, namely
  205. that users cannot depend on any particular behavior if the package environment
  206. at load time is inconsistent with what existed at compile time.
  207.  
  208. X3J13 voted in March 1989 (IN-SYNTAX)   to specify that compile-file must bind
  209. *readtable* to its current value at the time compile-file is called; the
  210. dynamic extent of the binding should encompass all of the file-loading
  211. activity. This allows a portable program to include forms such as
  212.  
  213. (in-package "FOO")
  214.  
  215. (eval-when (:execute :load-toplevel :compile-toplevel)
  216.   (setq *readtable* foo:my-readtable))
  217.  
  218. without performing a net global side effect on the loading environment. Such
  219. statements allow the remainder of such a file to be read either as interpreted
  220. code or by compile-file in a syntax determined by an alternative readtable.
  221.  
  222. X3J13 voted in June 1989 (LOAD-TRUENAME)   to require that compile-file bind
  223. two new variables *compile-file-pathname* and *compile-file-truename*; the
  224. dynamic extent of the bindings should encompass all of the file-compiling
  225. activity.
  226.  
  227. [Variable]
  228. *compile-verbose*
  229.  
  230. X3J13 voted in March 1989 (COMPILER-VERBOSITY)   to add *compile-verbose*. This
  231. variable provides the default for the :verbose argument to compile-file. Its
  232. initial value is implementation-dependent.
  233.  
  234. A proposal was submitted to X3J13 in October 1989 to rename this
  235. *compile-file-verbose* for consistency.
  236.  
  237. [Variable]
  238. *compile-print*
  239.  
  240. X3J13 voted in March 1989 (COMPILER-VERBOSITY)   to add *compile-print*. This
  241. variable provides the default for the :print argument to compile-file. Its
  242. initial value is implementation-dependent.
  243.  
  244. A proposal was submitted to X3J13 in October 1989 to rename this
  245. *compile-file-print* for consistency.
  246.  
  247. [Variable]
  248. *compile-file-pathname*
  249.  
  250. X3J13 voted in June 1989 (LOAD-TRUENAME)   to introduce
  251. *compile-file-pathname*; it is initially nil but compile-file binds it to a
  252. pathname that represents the file name given as the first argument to
  253. compile-file merged with the defaults (see merge-pathname).
  254.  
  255. [Variable]
  256. *compile-file-truename*
  257.  
  258. X3J13 voted in June 1989 (LOAD-TRUENAME)   to introduce
  259. *compile-file-truename*; it is initially nil but compile-file binds it to the
  260. ``true name'' of the pathname of the file being compiled. See truename.
  261.  
  262. [Special Form]
  263. load-time-value form [read-only-p]
  264.  
  265. X3J13 voted in March 1989 (LOAD-TIME-EVAL)   to add a mechanism for delaying
  266. evaluation of a form until it can be done in the run-time environment.
  267.  
  268. If a load-time-value expression is seen by compile-file, the compiler performs
  269. its normal semantic processing (such as macro expansion and translation into
  270. machine code) on the form, but arranges for the execution of the form to occur
  271. at load time in a null lexical environment, with the result of this evaluation
  272. then being treated as an immediate quantity (that is, as if originally quoted)
  273. at run time. It is guaranteed that the evaluation of the form will take place
  274. only once when the file is loaded, but the order of evaluation with respect to
  275. the execution of top-level forms in the file is unspecified.
  276.  
  277. If a load-time-value expression appears within a function compiled with
  278. compile, the form is evaluated at compile time in a null lexical environment.
  279. The result of this compile-time evaluation is treated as an immediate quantity
  280. in the compiled code.
  281.  
  282. In interpreted code, form is evaluated (by eval) in a null lexical environment
  283. and one value is returned. Implementations that implicitly compile (or
  284. partially compile) expressions passed to eval may evaluate the form only once,
  285. at the time this compilation is performed. This is intentionally similar to the
  286. freedom that implementations are given for the time of expanding macros in
  287. interpreted code.
  288.  
  289. If the same (as determined by eq) list (load-time-value form) is evaluated or
  290. compiled more than once, it is unspecified whether the form is evaluated only
  291. once or is evaluated more than once. This can happen both when an expression
  292. being evaluated or compiled shares substructure and when the same expression is
  293. passed to eval or to compile multiple times. Since a load-time-value expression
  294. may be referenced in more than one place and may be evaluated multiple times by
  295. the interpreter, it is unspecified whether each execution returns a ``fresh''
  296. object or returns the same object as some other execution. Users must use
  297. caution when destructively modifying the resulting object.
  298.  
  299. If two lists (load-time-value form) are equal but not eq, their values always
  300. come from distinct evaluations of form. Coalescing of these forms is not
  301. permitted.
  302.  
  303. The optional read-only-p argument designates whether the result may be
  304. considered a read-only constant. If nil (the default), the result must be
  305. considered ordinary, modifiable data. If t, the result is a read-only quantity
  306. that may, as appropriate, be copied into read-only space and may, as
  307. appropriate, be shared with other programs. The read-only-p argument is not
  308. evaluated and only the literal symbols t and nil are permitted.
  309.  
  310. This new feature addresses the same set of needs as the now-defunct #, reader
  311. syntax but in a cleaner and more general manner. Note that #, syntax was
  312. reliably useful only inside quoted structure (though this was not explicitly
  313. mentioned in the first edition), whereas a load-time-value form must appear
  314. outside quoted structure in a for-evaluation position.
  315.  
  316. See make-load-form.
  317. [change_end]
  318.  
  319. [Function]
  320. disassemble name-or-compiled-function
  321.  
  322. The argument should be a function object, a lambda-expression, or a symbol with
  323. a function definition. If the relevant function is not a compiled function, it
  324. is first compiled. In any case, the compiled code is then ``reverse-assembled''
  325. and printed out in a symbolic format. This is primarily useful for debugging
  326. the compiler, but also often of use to the novice who wishes to understand the
  327. workings of compiled code.
  328.  
  329. -------------------------------------------------------------------------------
  330. Implementation note: Implementors are encouraged to make the output readable,
  331. preferably with helpful comments.
  332. -------------------------------------------------------------------------------
  333.  
  334. [change_begin]
  335. X3J13 voted in March 1988 (DISASSEMBLE-SIDE-EFFECT)   to clarify that when
  336. disassemble compiles a function, it never installs the resulting
  337. compiled-function object in the symbol-function of a symbol.
  338.  
  339. X3J13 voted in March 1989 (FUNCTION-NAME)   to extend disassemble to accept as
  340. a name any function-name (a symbol or a list whose car is setf - see section
  341. 7.1). Thus one may write (disassemble '(setf cadr)) to disassemble the setf
  342. expansion function for cadr.
  343.  
  344. [Function]
  345. function-lambda-expression fn
  346.  
  347. X3J13 voted in January 1989 (FUNCTION-DEFINITION)   to add a new function to
  348. allow the source code for a defined function to be recovered. (The committee
  349. noted that the first edition provided no portable way to recover a
  350. lambda-expression once it had been compiled or evaluated to produce a
  351. function.)
  352.  
  353. This function takes one argument, which must be a function, and returns three
  354. values.
  355.  
  356. The first value is the defining lambda-expression for the function, or nil if
  357. that information is not available. The lambda-expression may have been
  358. preprocessed in some ways but should nevertheless be of a form suitable as an
  359. argument to the function compile or for use in the function special form.
  360.  
  361. The second value is nil if the function was definitely produced by closing a
  362. lambda-expression in the null lexical environment; it is some non-nil value if
  363. the function might have been closed in some non-null lexical environment.
  364.  
  365. The third value is the ``name'' of the function; this is nil if the name is not
  366. available or if the function had no name. The name is intended for debugging
  367. purposes only and may be any Lisp object (not necessarily one that would be
  368. valid for use as a name in a defun or function special form, for example).
  369.  
  370. -------------------------------------------------------------------------------
  371. Implementation note: An implementation is always free to return the values nil,
  372. t, nil from this function but is encouraged to make more useful information
  373. available as appropriate. For example, it may not be desirable for files of
  374. compiled code to retain the source lambda-expressions for use after the file is
  375. loaded, but it is probably desirable for functions produced by ``in-core''
  376. calls to eval, compile, or defun to retain the defining lambda-expression for
  377. debugging purposes. The function function-lambda-expression makes this
  378. information, if retained, accessible in a standard and portable manner.
  379. -------------------------------------------------------------------------------
  380.  
  381. [Macro]
  382. with-compilation-unit ({option-name option-value}*) {form}*
  383.  
  384. X3J13 voted in March 1989 (WITH-COMPILATION-UNIT)   to add
  385. with-compilation-unit, which executes the body forms as an implicit progn.
  386. Within the dynamic context of this form, warnings deferred by the compiler
  387. until ``the end of compilation'' will be deferred until the end of the
  388. outermost call to with-compilation-unit. The results are the same as those of
  389. the last of the forms (or nil if there is no form).
  390.  
  391. Each option-name is an unevaluated keyword; each option-value is evaluated. The
  392. set of keywords permitted may be extended by the implementation, but the only
  393. standard option keyword is :override; the default value for this option is nil.
  394. If with-compilation-unit forms are nested dynamically, only the outermost such
  395. call has any effect unless the :override value of an inner call is true.
  396.  
  397. The function compile-file should provide the effect of
  398.  
  399.   (with-compilation-unit (:override nil) ...)
  400.  
  401. around its code.
  402.  
  403. Any implementation-dependent extensions to this behavior may be provided only
  404. as the result of an explicit programmer request by use of an
  405. implementation-dependent keyword. It is forbidden for an implementation to
  406. attach additional meaning to a conforming use of this macro.
  407.  
  408. Note that not all compiler warnings are deferred. In some implementations, it
  409. may be that none are deferred. This macro only creates an interface to the
  410. capability where it exists, it does not require the creation of the capability.
  411. An implementation that does not defer any compiler warnings may correctly
  412. implement this macro as an expansion into a simple progn.
  413.  
  414. [change_end]
  415. -------------------------------------------------------------------------------
  416.  
  417.    *  Compiler Diagnostics
  418.    *  Compiled Functions
  419.    *  Compilation Environment
  420.    *  Similarity of Constants
  421.  
  422. -------------------------------------------------------------------------------
  423.  
  424. 25.1.1. Compiler Diagnostics
  425.  
  426. [change_begin]
  427. X3J13 voted in June 1987 (COMPILER-WARNING-STREAM)   to specify that compile
  428. and compile-file may output warning messages; any such messages should go to
  429. the stream that is the value of *error-output*.
  430.  
  431. X3J13 voted in June 1989 (COMPILER-DIAGNOSTICS)   to specify the use of
  432. conditions to signal various erroneous situations during compilation. First,
  433. note that error and warning conditions may be signaled either by the compiler
  434. itself or by code being processed by the compiler (for example, arbitrary
  435. errors may occur during compile-time macro expansion or processing of eval-when
  436. forms). Considering only those conditions signaled by the compiler (as opposed
  437. to during compilation):
  438.  
  439.    *  Conditions of type error may be signaled by the compiler in situations
  440.      where the compilation cannot proceed without intervention. Examples of
  441.      such situations may include errors when opening a file or syntax errors.
  442.  
  443.    *  Conditions of type warning may be signaled by the compiler in situations
  444.      where the standard explicitly states that a warning must, should, or may
  445.      be signaled. They may also be signaled when the compiler can determine
  446.      that a situation would result at runtime that would have undefined
  447.      consequences or would cause an error to be signaled. Examples of such
  448.      situations may include violations of type declarations, altering or
  449.      rebinding a constant defined with defconstant, calls to built-in Lisp
  450.      functions with too few or too many arguments or with malformed keyword
  451.      argument lists, referring to a variable declared ignore, or unrecognized
  452.      declaration specifiers.
  453.  
  454.    *  The compiler is permitted to signal diagnostics about matters of
  455.      programming style as conditions of type style-warning, a subtype of
  456.      warning. Although a style-warning condition may be signaled in these
  457.      situations, no implementation is required to do so. However, if an
  458.      implementation does choose to signal a condition, that condition will be
  459.      of type style-warning and will be signaled by a call to the function warn.
  460.      Examples of such situations may include redefinition of a function with an
  461.      incompatible argument list, calls to functions (other than built-in
  462.      functions) with too few or too many arguments or with malformed keyword
  463.      argument lists, unreferenced local variables not declared ignore, or
  464.      standard declaration specifiers that are ignored by the particular
  465.      compiler in question.
  466.  
  467. Both compile and compile-file are permitted (but not required) to establish a
  468. handler for conditions of type error. Such a handler might, for example, issue
  469. a warning and restart compilation from some implementation-dependent point in
  470. order to let the compilation proceed without manual intervention.
  471.  
  472. The functions compile and compile-file each return three values. See the
  473. definitions of these functions for descriptions of the first value. The second
  474. value is nil if no compiler diagnostics were issued, and true otherwise. The
  475. third value is nil if no compiler diagnostics other than style warnings were
  476. issued; a non-nil value indicates that there were ``serious'' compiler
  477. diagnostics issued or that other conditions of type error or warning (but not
  478. style-warning) were signaled during compilation.
  479. [change_end]
  480.  
  481. -------------------------------------------------------------------------------
  482.  
  483. 25.1.2. Compiled Functions
  484.  
  485. [change_begin]
  486. X3J13 voted in June 1989 (COMPILED-FUNCTION-REQUIREMENTS)   to impose certain
  487. requirements on the functions produced by the compilation process.
  488.  
  489. If a function is of type compiled-function, then all macro calls appearing
  490. lexically within the function have already been expanded and will not be
  491. expanded again when the function is called. The process of compilation
  492. effectively turns every macrolet or symbol-macrolet construct into a progn (or
  493. a locally) with all instances of the local macros in the body fully expanded.
  494.  
  495. If a function is of type compiled-function, then all load-time-value forms
  496. appearing lexically within the function have already been pre-evaluated and
  497. will not be evaluated again when the function is called.
  498.  
  499. Implementations are free to classify every function as a compiled-function
  500. provided that all functions satisfy the preceding requirements. Conversely, it
  501. is permissible for a function that is not a compiled-function to satisfy the
  502. preceding requirements.
  503.  
  504. If one or more functions are defined in a file that is compiled with
  505. compile-file and the compiled file is subsequently loaded by the function load,
  506. the resulting loaded function definitions must be of type compiled-function.
  507.  
  508. The function compile must produce an object of type compiled-function as the
  509. value that is either returned or stored into the symbol-function of a symbol
  510. argument.
  511.  
  512. Note that none of these restrictions addresses questions of the compilation
  513. technology or target instruction set. For example, a compiled function does not
  514. necessarily consist of native machine instructions. These requirements merely
  515. specify the behavior of the type system with respect to certain actions taken
  516. by compile, compile-file, and load.
  517. [change_end]
  518.  
  519. -------------------------------------------------------------------------------
  520.  
  521. 25.1.3. Compilation Environment
  522.  
  523. [change_begin]
  524. X3J13 voted in June 1989 (COMPILE-ENVIRONMENT-CONSISTENCY)   to specify what
  525. information must be available at compile time for correct compilation and what
  526. need not be available until run time.
  527.  
  528. The following information must be present in the compile-time environment for a
  529. program to be compiled correctly. This information need not also be present in
  530. the run-time environment.
  531.  
  532.    *  In conforming code, macros referenced in the code being compiled must
  533.      have been previously defined in the compile-time environment. The compiler
  534.      must treat as a function call any form that is a list whose car is a
  535.      symbol that does not name a macro or special form. (This implies that setf
  536.      methods must also be available at compile time.)
  537.  
  538.    *  In conforming code, proclamations for special variables must be made in
  539.      the compile-time environment before any bindings of those variables are
  540.      processed by the compiler. The compiler must treat any binding of an
  541.      undeclared variable as a lexical binding.
  542.  
  543. The compiler may incorporate the following kinds of information into the code
  544. it produces, if the information is present in the compile-time environment and
  545. is referenced within the code being compiled; however, the compiler is not
  546. required to do so. When compile-time and run-time definitions differ, it is
  547. unspecified which will prevail within the compiled code (unless some other
  548. behavior is explicitly specified below). It is also permissible for an
  549. implementation to signal an error at run time on detecting such a discrepancy.
  550. In all cases, the absence of the information at compile time is not an error,
  551. but its presence may enable the compiler to generate more efficient code.
  552.  
  553.    *  The compiler may assume that functions that are defined and declared
  554.      inline in the compile-time environment will retain the same definitions at
  555.      run time.
  556.  
  557.    *  The compiler may assume that, within a named function, a recursive call
  558.      to a function of the same name refers to the same function, unless that
  559.      function has been declared notinline. (This permits tail-recursive calls
  560.      of a function to itself to be compiled as jumps, for example, thereby
  561.      turning certain recursive schemas into efficient loops.)
  562.  
  563.    *  In the absence of notinline declarations to the contrary, compile-file
  564.      may assume that a call within the file being compiled to a named function
  565.      that is defined in that file refers to that function. (This rule permits
  566.      block compilation of files.) The behavior of the program is unspecified if
  567.      functions are redefined individually at run time.
  568.  
  569.    *  The compiler may assume that the signature (or ``interface contract'') of
  570.      all built-in Common Lisp functions will not change. In addition, the
  571.      compiler may treat all built-in Common Lisp functions as if they had been
  572.      proclaimed inline.
  573.  
  574.    *  The compiler may assume that the signature (or ``interface contract'') of
  575.      functions with ftype information available will not change.
  576.  
  577.    *  The compiler may ``wire in'' (that is, open-code or inline) the values of
  578.      symbolic constants that have been defined with defconstant in the
  579.      compile-time environment.
  580.  
  581.    *  The compiler may assume that any type definition made with defstruct or
  582.      deftype in the compile-time environment will retain the same definition in
  583.      the run-time environment. It may also assume that a class defined by
  584.      defclass in the compile-time environment will be defined in the run-time
  585.      environment in such a way as to have the same superclasses and metaclass.
  586.      This implies that subtype/supertype relationships of type specifiers will
  587.      not change between compile time and run time. (Note that it is not an
  588.      error for an unknown type to appear in a declaration at compile time,
  589.      although it is reasonable for the compiler to emit a warning in such a
  590.      case.)
  591.  
  592.    *  The compiler may assume that if type declarations are present in the
  593.      compile-time environment, the corresponding variables and functions
  594.      present in the run-time environment will actually be of those types. If
  595.      this assumption is violated, the run-time behavior of the program is
  596.      undefined.
  597.  
  598. The compiler must not make any additional assumptions about consistency between
  599. the compile-time and run-time environments. In particular, the compiler may not
  600. assume that functions that are defined in the compile-time environment will
  601. retain either the same definition or the same signature at run time, except as
  602. described above. Similarly, the compiler may not signal an error if it sees a
  603. call to a function that is not defined at compile time, since that function may
  604. be provided at run time.
  605.  
  606. X3J13 voted in January 1989 (COMPILE-FILE-HANDLING-OF-TOP-LEVEL-FORMS)   to
  607. specify the compile-time side effects of processing various macro forms.
  608.  
  609. Calls to defining macros such as defmacro or defvar appearing within a file
  610. being processed by compile-file normally have compile-time side effects that
  611. affect how subsequent forms in the same file are compiled. A convenient model
  612. for explaining how these side effects happen is that each defining macro
  613. expands into one or more eval-when forms and that compile-time side effects are
  614. caused by calls occurring in the body of an (eval-when (:compile-toplevel) ...)
  615. form.
  616.  
  617. The affected defining macros and their specific side effects are as follows. In
  618. each case, it is identified what a user must do to ensure that a program is
  619. conforming, and what a compiler must do in order to correctly process a
  620. conforming program.
  621.  
  622. deftype
  623.      The user must ensure that the body of a deftype form is evaluable at
  624.      compile time if the type is referenced in subsequent type declarations.
  625.      The compiler must ensure that a type specifier defined by deftype is
  626.      recognized in subsequent type declarations. If the expansion of a type
  627.      specifier is not defined fully at compile time (perhaps because it expands
  628.      into an unknown type specifier or a satisfies of a named function that
  629.      isn't defined in the compile-time environment), an implementation may
  630.      ignore any references to this type in declarations and may signal a
  631.      warning.
  632.  
  633. defmacro and define-modify-macro
  634.      The compiler must store macro definitions at compile time, so that
  635.      occurrences of the macro later on in the file can be expanded correctly.
  636.      The user must ensure that the body of the macro is evaluable at compile
  637.      time if it is referenced within the file being compiled.
  638.  
  639. defun
  640.      No required compile-time side effects are associated with defun forms. In
  641.      particular, defun does not make the function definition available at
  642.      compile time. An implementation may choose to store information about the
  643.      function for the purposes of compile-time error checking (such as checking
  644.      the number of arguments on calls) or to permit later inline expansion of
  645.      the function.
  646.  
  647. defvar and defparameter
  648.      The compiler must recognize that the variables named by these forms have
  649.      been proclaimed special. However, it must not evaluate the initial-value
  650.      form or set the variable at compile time.
  651.  
  652. defconstant
  653.      The compiler must recognize that the symbol names a constant. An
  654.      implementation may choose to evaluate the value-form at compile time, load
  655.      time, or both. Therefore the user must ensure that the value-form is
  656.      evaluable at compile time (regardless of whether or not references to the
  657.      constant appear in the file) and that it always evaluates to the same
  658.      value. (There has been considerable variance among implementations on this
  659.      point. The effect of this specification is to legitimize all of the
  660.      implementation variants by requiring care of the user.)
  661.  
  662. defsetf and define-setf-method
  663.      The compiler must make setf methods available so that they may be used to
  664.      expand calls to setf later on in the file. Users must ensure that the body
  665.      of a call to define-setf-method or the complex form of defsetf is
  666.      evaluable at compile time if the corresponding place is referred to in a
  667.      subsequent setf in the same file. The compiler must make these setf
  668.      methods available to compile-time calls to get-setf-method when its
  669.      environment argument is a value received as the &environment parameter of
  670.      a macro.
  671.  
  672. defstruct
  673.      The compiler must make the structure type name recognized as a valid type
  674.      name in subsequent declarations (as described above for deftype) and make
  675.      the structure slot accessors known to setf. In addition, the compiler must
  676.      save enough information so that further defstruct definitions can include
  677.      (with the :include option) a structure type defined earlier in the file
  678.      being compiled. The functions that defstruct generates are not defined in
  679.      the compile-time environment, although the compiler may save enough
  680.      information about the functions to allow inline expansion of subsequent
  681.      calls to these functions. The #S reader syntax may or may not be available
  682.      for that structure type at compile time.
  683.  
  684. define-condition
  685.      The rules are essentially the same as those for defstruct. The compiler
  686.      must make the condition type recognizable as a valid type name, and it
  687.      must be possible to reference the condition type as the parent-type of
  688.      another condition type in a subsequent define-condition form in the file
  689.      being compiled.
  690.  
  691. defpackage
  692.      All of the actions normally performed by the defpackage macro at load time
  693.      must also be performed at compile time.
  694.  
  695. Compile-time side effects may cause information about a definition to be stored
  696. in a different manner from information about definitions processed either
  697. interpretively or by loading a compiled file. In particular, the information
  698. stored by a defining macro at compile time may or may not be available to the
  699. interpreter (either during or after compilation) or during subsequent calls to
  700. compile or compile-file. For example, the following code is not portable
  701. because it assumes that the compiler stores the macro definition of foo where
  702. it is available to the interpreter.
  703.  
  704. (defmacro foo (x) `(car ,x))
  705.  
  706. (eval-when (:execute :compile-toplevel :load-toplevel)
  707.   (print (foo '(a b c))))     ;Wrong
  708.  
  709. The goal may be accomplished portably by including the macro definition within
  710. the eval-when form:
  711.  
  712. (eval-when (eval compile load)
  713.   (defmacro foo (x) `(car ,x))
  714.   (print (foo '(a b c))))     ;Right
  715.  
  716. declaim
  717.  
  718.      X3J13 voted in June 1989 (PROCLAIM-ETC-IN-COMPILE-FILE)   to add a new
  719.      macro declaim for making proclamations recognizable at compile time. The
  720.      declaration specifiers in the declaim form are effectively proclaimed at
  721.      compile time so as to affect compilation of subsequent forms. (Note that
  722.      compiler processing of a call to proclaim does not have any compile-time
  723.      side effects, for proclaim is a function.)
  724.  
  725. in-package
  726.  
  727.      X3J13 voted in March 1989 (IN-PACKAGE-FUNCTIONALITY)   to specify that all
  728.      of the actions normally performed by the in-package macro at load time
  729.      must also be performed at compile time.
  730.  
  731. X3J13 voted in June 1989 (CLOS-MACRO-COMPILATION)   to specify the compile-time
  732. side effects of processing various CLOS-related macro forms. Top-level calls to
  733. the CLOS defining macros have the following compile-time side effects; any
  734. other compile-time behavior is explicitly left unspecified.
  735.  
  736. defclass
  737.      The class name may appear in subsequent type declarations and can be used
  738.      as a specializer in subsequent defmethod forms. Thus the compile-time
  739.      behavior of defclass is similar to that of deftype or defstruct.
  740.  
  741. defgeneric
  742.      The generic function can be referenced in subsequent defmethod forms, but
  743.      the compiler does not arrange for the generic function to be callable at
  744.      compile time.
  745.  
  746. defmethod
  747.      The compiler does not arrange for the method to be callable at compile
  748.      time. If there is a generic function with the same name defined at compile
  749.      time, compiling a defmethod form does not add the method to that generic
  750.      function; the method is added to the generic function only when the
  751.      defmethod form is actually executed.
  752.  
  753.      The error-signaling behavior described in the specification of defmethod
  754.      in chapter 28 (if the function isn't a generic function or if the
  755.      lambda-list is not congruent) occurs only when the defining form is
  756.      executed, not at compile time.
  757.  
  758.      The forms in eql parameter specializers are evaluated when the defmethod
  759.      form is executed. The compiler is permitted to build in knowledge about
  760.      what the form in an eql specializer will evaluate to in cases where the
  761.      ultimate result can be syntactically inferred without actually evaluating
  762.      it.
  763.  
  764. define-method-combination
  765.      The method combination can be used in subsequent defgeneric forms.
  766.  
  767.      The body of a define-method-combination form is evaluated no earlier than
  768.      when the defining macro is executed and possibly as late as generic
  769.      function invocation time. The compiler may attempt to evaluate these forms
  770.      at compile time but must not depend on being able to do so.
  771.  
  772. [change_end]
  773.  
  774. -------------------------------------------------------------------------------
  775.  
  776. 25.1.4. Similarity of Constants
  777.  
  778. [change_begin]
  779. X3J13 voted in March 1989 (CONSTANT-COMPILABLE-TYPES)   to specify what objects
  780. can be in compiled constants and what relationship there must be between a
  781. constant passed to the compiler and the one that is established by compiling it
  782. and then loading its file.
  783.  
  784. The key is a definition of an equivalence relationship called ``similarity as
  785. constants'' between Lisp objects. Code passed through the file compiler and
  786. then loaded must behave as though quoted constants in it are similar in this
  787. sense to quoted constants in the corresponding source code. An object may be
  788. used as a quoted constant processed by compile-file if and only if the compiler
  789. can guarantee that the resulting constant established by loading the compiled
  790. file is ``similar as a constant'' to the original. Specific requirements are
  791. spelled out below.
  792.  
  793. Some types of objects, such as streams, are not supported in constants
  794. processed by the file compiler. Such objects may not portably appear as
  795. constants in code processed with compile-file. Conforming implementations are
  796. required to handle such objects either by having the compiler or loader
  797. reconstruct an equivalent copy of the object in some implementation-specific
  798. manner or by having the compiler signal an error.
  799.  
  800. Of the types supported in constants, some are treated as aggregate objects. For
  801. these types, being similar as constants is defined recursively. We say that an
  802. object of such a type has certain ``basic attributes''; to be similar as a
  803. constant to another object, the values of the corresponding attributes of the
  804. two objects must also be similar as constants.
  805.  
  806. A definition of this recursive form has problems with any circular or
  807. infinitely recursive object such as a list that is an element of itself. We use
  808. the idea of depth-limited comparison and say that two objects are similar as
  809. constants if they are similar at all finite levels. This idea is implicit in
  810. the definitions below, and it applies in all the places where attributes of two
  811. objects are required to be similar as constants. The question of handling
  812. circular constants is the subject of a separate vote by X3J13 (see below).
  813.  
  814. The following terms are used throughout this section. The term constant refers
  815. to a quoted or self-evaluating constant, not a named constant defined by
  816. defconstant. The term source code is used to refer to the objects constructed
  817. when compile-file calls read (or the equivalent) and to additional objects
  818. constructed by macro expansion during file compilation. The term compiled code
  819. is used to refer to objects constructed by load.
  820.  
  821. Two objects are similar as a constant if and only if they are both of one of
  822. the types listed below and satisfy the additional requirements listed for that
  823. type.
  824.  
  825. number
  826.  
  827.      Two numbers are similar as constants if they are of the same type and
  828.      represent the same mathematical value.
  829.  
  830. character
  831.  
  832.      Two characters are similar as constants if they both represent the same
  833.      character. (The intent is that this be compatible with how eql is defined
  834.      on characters.)
  835.  
  836. symbol
  837.      X3J13 voted in June 1989 (COMPILE-FILE-SYMBOL-HANDLING)   to define
  838.      similarity as a constant for interned symbols. A symbol S appearing in the
  839.      source code is similar as a constant to a symbol S' in the compiled code
  840.      if their print names are similar as constants and either of the following
  841.      conditions holds:
  842.         o  S is accessible in *package* at compile time and S' is accessible in
  843.           *package* at load time.
  844.         o  S' is accessible in the package that is similar as a constant to the
  845.           home package of symbol S.
  846.      The ``similar as constants'' relationship for interned symbols has nothing
  847.      to do with *readtable* or how the function read would parse the characters
  848.      in the print name of the symbol.
  849.  
  850.      An uninterned symbol in the source code is similar as a constant to an
  851.      uninterned symbol in the compiled code if their print names are similar as
  852.      constants.
  853.  
  854. package
  855.  
  856.      A package in the source code is similar as a constant to a package in the
  857.      compiled code if their names are similar as constants. Note that the
  858.      loader finds the corresponding package object as if by calling
  859.      find-package with the package name as an argument. An error is signaled if
  860.      no package of that name exists at load time.
  861.  
  862. random-state
  863.  
  864.      We say that two random-state objects are functionally equivalent if
  865.      applying random to them repeatedly always produces the same pseudo-random
  866.      numbers in the same order.
  867.  
  868.      Two random-states are similar as constants if and only if copies of them
  869.      made via make-random-state are functionally equivalent. (Note that a
  870.      constant random-state object cannot be used as the state argument to the
  871.      function random because random performs a side effect on that argument.)
  872.  
  873. cons
  874.  
  875.      Two conses are similar as constants if the values of their respective car
  876.      and cdr attributes are similar as constants.
  877.  
  878. array
  879.  
  880.      Two arrays are similar as constants if the corresponding values of each of
  881.      the following attributes are similar as constants: for vectors
  882.      (one-dimensional arrays), the length and element-type and the result of
  883.      elt for all valid indices; for all other arrays, the array-rank, the
  884.      result of array-dimension for all valid axis numbers, the
  885.      array-element-type, and the result of aref for all valid indices. (The
  886.      point of distinguishing vectors is to take any fill pointers into
  887.      account.)
  888.  
  889.      If the array in the source code is a simple-array, then the corresponding
  890.      array in the compiled code must also be a simple-array, but if the array
  891.      in the source code is displaced, has a fill pointer, or is adjustable, the
  892.      corresponding array in the compiled code is permitted to lack any or all
  893.      of these qualities.
  894.  
  895. hash-table
  896.  
  897.      Two hash tables are similar as constants if they meet three requirements.
  898.      First, they must have the same test (for example, both are eql hash tables
  899.      or both are equal hash tables). Second, there must be a unique bijective
  900.      correspondence between the keys of the two tables, such that the
  901.      corresponding keys are similar as constants. Third, for all keys, the
  902.      values associated with two corresponding keys must be similar as
  903.      constants.
  904.  
  905.      If there is more than one possible one-to-one correspondence between the
  906.      keys of the two tables, it is unspecified whether the two tables are
  907.      similar as constants. A conforming program cannot use such a table as a
  908.      constant.
  909.  
  910. pathname
  911.  
  912.      Two pathnames are similar as constants if all corresponding pathname
  913.      components are similar as constants.
  914.  
  915. stream, readtable, and method
  916.  
  917.      Objects of these types are not supported in compiled constants.
  918.  
  919. function
  920.  
  921.      X3J13 voted in June 1989 (CONSTANT-FUNCTION-COMPILATION)   to specify that
  922.      objects of type function are not supported in compiled constants.
  923.  
  924. structure and standard-object
  925.  
  926.      X3J13 voted in March 1989 (LOAD-OBJECTS)   to introduce a facility based
  927.      on the Common Lisp Object System whereby a user can specify how
  928.      compile-file and load must cooperate to reconstruct compile-time constant
  929.      objects at load time (see make-load-form).
  930.  
  931. X3J13 voted in March 1989 (CONSTANT-COLLAPSING)   to specify the circumstances
  932. under which constants may be coalesced in compiled code.
  933.  
  934. Suppose A and B are two objects used as quoted constants in the source code,
  935. and that A' and B' are the corresponding objects in the compiled code. If A'
  936. and B' are eql but A and B were not eql, then we say that A and B have been
  937. coalesced by the compiler.
  938.  
  939. An implementation is permitted to coalesce constants appearing in code to be
  940. compiled if and only if they are similar as constants, except that objects of
  941. type symbol, package, structure, or standard-object obey their own rules and
  942. may not be coalesced by a separate mechanism.
  943.  
  944. -------------------------------------------------------------------------------
  945. Rationale: Objects of type symbol and package cannot be coalesced because the
  946. fact that they are named, interned objects means they are already as coalesced
  947. as it is useful for them to be. Uninterned symbols could perhaps be coalesced,
  948. but that was thought to be more dangerous than useful. Structures and objects
  949. could be coalesced if a ``similar as a constant'' predicate were defined for
  950. them; it would be a generic function. However, at present there is no such
  951. predicate. Currently make-load-form provides a protocol by which compile-file
  952. and load work together to construct an object in the compiled code that is
  953. equivalent to the object in the source code; a different mechanism would have
  954. to be added to permit coalescing.
  955. -------------------------------------------------------------------------------
  956.  
  957. Note that coalescing is possible only because it is forbidden to destructively
  958. modify constants (CONSTANT-MODIFICATION)   (see quote).
  959.  
  960. X3J13 voted in March 1989 (CONSTANT-CIRCULAR-COMPILATION)   to specify that
  961. objects containing circular or infinitely recursive references may legitimately
  962. appear as constants to be compiled. The compiler is required to preserve
  963. eql-ness of substructures within a file compiled by compile-file.
  964. [change_end]
  965.  
  966. -------------------------------------------------------------------------------
  967.  
  968. 25.2. Documentation
  969.  
  970. [old_change_begin]
  971. A simple facility is provided for attaching strings to symbols for the purpose
  972. of on-line documentation. Rather than using the property list of the symbol, a
  973. separate function documentation is provided so that implementations can
  974. optimize the storage of documentation strings.
  975.  
  976. [Function]
  977. documentation symbol doc-type
  978.  
  979. This function returns the documentation string of type doc-type for the symbol,
  980. or nil if none exists. Both arguments must be symbols. Some kinds of
  981. documentation are provided automatically by certain Common Lisp constructs if
  982. the user writes an optional documentation string within them:
  983.  
  984. Construct               Documentation Type
  985. ============================================
  986. defvar                  variable
  987. defparameter            variable
  988. defconstant             variable
  989. defun                   function
  990. defmacro                function
  991. defstruct               structure
  992. deftype                 type
  993. defsetf                 setf
  994. ============================================
  995.  
  996. In addition, names of special forms may also have function documentation.
  997. (Macros and special forms are not really functions, of course, but it is
  998. convenient to group them with functions for documentation purposes.)
  999.  
  1000. setf may be used with documentation to update documentation information.
  1001. [old_change_end]
  1002.  
  1003. [change_begin]
  1004. X3J13 voted in June 1988 (CLOS)   to make documentation a CLOS generic function
  1005. (see chapter 28).
  1006.  
  1007. X3J13 voted in March 1989 (FUNCTION-NAME)   to extend documentation to accept
  1008. any function-name (a symbol or a list whose car is setf - see section 7.1).
  1009. Thus one may write (documentation '(setf cadr) 'function) to determine whether
  1010. there is any documentation for a setf expansion function for cadr.
  1011. [change_end]
  1012.  
  1013. -------------------------------------------------------------------------------
  1014.  
  1015. 25.4. Environment Inquiries
  1016.  
  1017. Environment inquiry functions provide information about the environment in
  1018. which a Common Lisp program is being executed. They are described here in two
  1019. categories: first, those dealing with determination and measurement of time,
  1020. and second, all the others, most of which deal with identification of the
  1021. computer hardware and software.
  1022.  
  1023. -------------------------------------------------------------------------------
  1024.  
  1025.    *  Time Functions
  1026.    *  Other Environment Inquiries
  1027.  
  1028. -------------------------------------------------------------------------------
  1029.  
  1030. 25.4.1. Time Functions
  1031.  
  1032. Time is represented in three different ways in Common Lisp: Decoded Time,
  1033. Universal Time, and Internal Time. The first two representations are used
  1034. primarily to represent calendar time and are precise only to one second.
  1035. Internal Time is used primarily to represent measurements of computer time
  1036. (such as run time) and is precise to some implementation-dependent fraction of
  1037. a second, as specified by internal-time-units-per-second. Decoded Time format
  1038. is used only for absolute time indications. Universal Time and Internal Time
  1039. formats are used for both absolute and relative times.
  1040.  
  1041. Decoded Time format represents calendar time as a number of components:
  1042.  
  1043.    *  Second: an integer between 0 and 59, inclusive.
  1044.  
  1045.    *  Minute: an integer between 0 and 59, inclusive.
  1046.  
  1047.    *  Hour: an integer between 0 and 23, inclusive.
  1048.  
  1049.    *  Date: an integer between 1 and 31, inclusive (the upper limit actually
  1050.      depends on the month and year, of course).
  1051.  
  1052.    *  Month: an integer between 1 and 12, inclusive; 1 means January, 12 means
  1053.      December.
  1054.  
  1055.    *  Year: an integer indicating the year A.D. However, if this integer is
  1056.      between 0 and 99, the ``obvious'' year is used; more precisely, that year
  1057.      is assumed that is equal to the integer modulo 100 and within fifty years
  1058.      of the current year (inclusive backwards and exclusive forwards). Thus, in
  1059.      the year 1978, year 28 is 1928 but year 27 is 2027. (Functions that return
  1060.      time in this format always return a full year number.)
  1061.  
  1062. -------------------------------------------------------------------------------
  1063. Compatibility note: This is incompatible with the Lisp Machine Lisp definition
  1064. in two ways. First, in Lisp Machine Lisp a year between 0 and 99 always has
  1065. 1900 added to it. Second, in Lisp Machine Lisp time functions return the
  1066. abbreviated year number between 0 and 99 rather than the full year number. The
  1067. incompatibility is prompted by the imminent arrival of the twenty-first
  1068. century. Note that (mod year 100) always reliably converts a year number to the
  1069. abbreviated form, while the inverse conversion can be very difficult.
  1070. -------------------------------------------------------------------------------
  1071.  
  1072.    *  Day-of-week: an integer between 0 and 6, inclusive; 0 means Monday, 1
  1073.      means Tuesday, and so on; 6 means Sunday.
  1074.  
  1075.    *  Daylight-saving-time-p: a flag that, if not nil, indicates that daylight
  1076.      saving time is in effect.
  1077.  
  1078.    *  Time-zone: an integer specified as the number of hours west of GMT
  1079.      (Greenwich Mean Time). For example, in Massachusetts the time zone is 5,
  1080.      and in California it is 8. Any adjustment for daylight saving time is
  1081.      separate from this.
  1082.  
  1083. [change_begin]
  1084. X3J13 voted in March 1989 (TIME-ZONE-NON-INTEGER)   to specify that the time
  1085. zone part of Decoded Time need not be an integer, but may be any rational
  1086. number (either an integer or a ratio) in the range -24 to 24 (inclusive on both
  1087. ends) that is an integral multiple of 1/3600.
  1088.  
  1089. -------------------------------------------------------------------------------
  1090. Rationale: For all possible time designations to be accommodated, it is
  1091. necessary to allow the time zone to be non-integral, for some places in the
  1092. world have time standards offset from Greenwich Mean Time by a non-integral
  1093. number of hours.
  1094.  
  1095. There appears to be no user demand for floating-point time zones. Since such
  1096. zones would introduce inexact arithmetic, X3J13 did not consider adding them at
  1097. this time.
  1098.  
  1099. This specification does require time zones to be represented as integral
  1100. multiples of 1 second (rather than 1 hour). This prevents problems that could
  1101. otherwise occur in converting Decoded Time to Universal Time.
  1102. -------------------------------------------------------------------------------
  1103.  
  1104. [change_end]
  1105.  
  1106. Universal Time represents time as a single non-negative integer. For relative
  1107. time purposes, this is a number of seconds. For absolute time, this is the
  1108. number of seconds since midnight, January 1, 1900 GMT. Thus the time 1 is
  1109. 00:00:01 (that is, 12:00:01 A.M.) on January 1, 1900 GMT. Similarly, the time
  1110. 2398291201 corresponds to time 00:00:01 on January 1, 1976 GMT. Recall that the
  1111. year 1900 was not a leap year; for the purposes of Common Lisp, a year is a
  1112. leap year if and only if its number is divisible by 4, except that years
  1113. divisible by 100 are not leap years, except that years divisible by 400 are
  1114. leap years. Therefore the year 2000 will be a leap year. (Note that the ``leap
  1115. seconds'' that are sporadically inserted by the world's official timekeepers as
  1116. an additional correction are ignored; Common Lisp assumes that every day is
  1117. exactly 86400 seconds long.) Universal Time format is used as a standard time
  1118. representation within the ARPANET; see reference [22]. Because the Common Lisp
  1119. Universal Time representation uses only non-negative integers, times before the
  1120. base time of midnight, January 1, 1900 GMT cannot be processed by Common Lisp.
  1121.  
  1122. Internal Time also represents time as a single integer, but in terms of an
  1123. implementation-dependent unit. Relative time is measured as a number of these
  1124. units. Absolute time is relative to an arbitrary time base, typically the time
  1125. at which the system began running.
  1126.  
  1127. [Function]
  1128. get-decoded-time
  1129.  
  1130. The current time is returned in Decoded Time format. Nine values are returned:
  1131. second, minute, hour, date, month, year, day-of-week, daylight-saving-time-p,
  1132. and time-zone.
  1133.  
  1134. -------------------------------------------------------------------------------
  1135. Compatibility note: In Lisp Machine Lisp time-zone is not currently returned.
  1136. Consider, however, the use of Common Lisp in some mobile vehicle. It is
  1137. entirely plausible that the time zone might change from time to time.
  1138. -------------------------------------------------------------------------------
  1139.  
  1140. [Function]
  1141. get-universal-time
  1142.  
  1143. The current time of day is returned as a single integer in Universal Time
  1144. format.
  1145.  
  1146. [Function]
  1147. decode-universal-time universal-time &optional time-zone
  1148.  
  1149. The time specified by universal-time in Universal Time format is converted to
  1150. Decoded Time format. Nine values are returned: second, minute, hour, date,
  1151. month, year, day-of-week, daylight-saving-time-p, and time-zone.
  1152.  
  1153. -------------------------------------------------------------------------------
  1154. Compatibility note: In Lisp Machine Lisp time-zone is not currently returned.
  1155. Consider, however, the use of Common Lisp in some mobile vehicle. It is
  1156. entirely plausible that the time zone might change from time to time.
  1157. -------------------------------------------------------------------------------
  1158. The time-zone argument defaults to the current time zone.
  1159.  
  1160. [change_begin]
  1161. X3J13 voted in January 1989 (DECODE-UNIVERSAL-TIME-DAYLIGHT)   to specify that
  1162. decode-universal-time, like encode-universal-time, ignores daylight saving time
  1163. information if a time-zone is explicitly specified; in this case the returned
  1164. daylight-saving-time-p value will necessarily be nil even if daylight saving
  1165. time happens to be in effect in that time zone at the specified time.
  1166. [change_end]
  1167.  
  1168. [Function]
  1169. encode-universal-time second minute hour date month year &optional time-zone
  1170.  
  1171. The time specified by the given components of Decoded Time format is encoded
  1172. into Universal Time format and returned. If you do not specify time-zone, it
  1173. defaults to the current time zone adjusted for daylight saving time. If you
  1174. provide time-zone explicitly, no adjustment for daylight saving time is
  1175. performed.
  1176.  
  1177. [Constant]
  1178. internal-time-units-per-second
  1179.  
  1180. This value is an integer, the implementation-dependent number of internal time
  1181. units in a second. (The internal time unit must be chosen so that one second is
  1182. an integral multiple of it.)
  1183.  
  1184. -------------------------------------------------------------------------------
  1185. Rationale: The reason for allowing the internal time units to be
  1186. implementation-dependent is so that get-internal-run-time and
  1187. get-internal-real-time can execute with minimum overhead. The idea is that it
  1188. should be very likely that a fixnum will suffice as the returned value from
  1189. these functions. This probability can be tuned to the implementation by trading
  1190. off the speed of the machine against the word size. Any particular unit will be
  1191. inappropriate for some implementations: a microsecond is too long for a very
  1192. fast machine, while a much smaller unit would force many implementations to
  1193. return bignums for most calls to get-internal-time, rendering that function
  1194. less useful for accurate timing measurements.
  1195. -------------------------------------------------------------------------------
  1196.  
  1197. [Function]
  1198. get-internal-run-time
  1199.  
  1200. The current run time is returned as a single integer in Internal Time format.
  1201. The precise meaning of this quantity is implementation-dependent; it may
  1202. measure real time, run time, CPU cycles, or some other quantity. The intent is
  1203. that the difference between the values of two calls to this function be the
  1204. amount of time between the two calls during which computational effort was
  1205. expended on behalf of the executing program.
  1206.  
  1207. [Function]
  1208. get-internal-real-time
  1209.  
  1210. The current time is returned as a single integer in Internal Time format. This
  1211. time is relative to an arbitrary time base, but the difference between the
  1212. values of two calls to this function will be the amount of elapsed real time
  1213. between the two calls, measured in the units defined by
  1214. internal-time-units-per-second.
  1215.  
  1216. [Function]
  1217. sleep seconds
  1218.  
  1219. (sleep n) causes execution to cease and become dormant for approximately n
  1220. seconds of real time, whereupon execution is resumed. The argument may be any
  1221. non-negative non-complex number. sleep returns nil.
  1222.  
  1223. -------------------------------------------------------------------------------
  1224.  
  1225. 25.4.2. Other Environment Inquiries
  1226.  
  1227. For any of the following functions, if no appropriate and relevant result can
  1228. be produced, nil is returned instead of a string.
  1229.  
  1230. -------------------------------------------------------------------------------
  1231. Rationale: These inquiry facilities are functions rather than variables against
  1232. the possibility that a Common Lisp process might migrate from machine to
  1233. machine. This need not happen in a distributed environment; consider, for
  1234. example, dumping a core image file containing a compiler and then shipping it
  1235. to another site.
  1236. -------------------------------------------------------------------------------
  1237.  
  1238. [Function]
  1239. lisp-implementation-type
  1240.  
  1241. A string is returned that identifies the generic name of the particular Common
  1242. Lisp implementation. Examples: "Spice LISP", "Zetalisp".
  1243.  
  1244. [Function]
  1245. lisp-implementation-version
  1246.  
  1247. A string is returned that identifies the version of the particular Common Lisp
  1248. implementation; this information should be of use to maintainers of the
  1249. implementation. Examples: "1192", "53.7 with complex numbers", "1746.9A, NEWIO
  1250. 53, ETHER 5.3".
  1251.  
  1252. [Function]
  1253. machine-type
  1254.  
  1255. A string is returned that identifies the generic name of the computer hardware
  1256. on which Common Lisp is running. Examples: "IMLAC", "DEC PDP-10", "DEC
  1257. VAX-11/780".
  1258.  
  1259. [Function]
  1260. machine-version
  1261.  
  1262. A string is returned that identifies the version of the computer hardware on
  1263. which Common Lisp is running. Example: "KL10, microcode 9".
  1264.  
  1265. [Function]
  1266. machine-instance
  1267.  
  1268. A string is returned that identifies the particular instance of the computer
  1269. hardware on which Common Lisp is running; this might be a local nickname, for
  1270. example, or a serial number. Examples: "MIT-MC", "CMU GP-VAX".
  1271.  
  1272. [Function]
  1273. software-type
  1274.  
  1275. A string is returned that identifies the generic name of any relevant
  1276. supporting software. Examples: "Spice", "TOPS-20", "ITS".
  1277.  
  1278. [Function]
  1279. software-version
  1280.  
  1281. A string is returned that identifies the version of any relevant supporting
  1282. software; this information should be of use to maintainers of the
  1283. implementation.
  1284.  
  1285. [Function]
  1286. short-site-name 
  1287. long-site-name
  1288.  
  1289. A string is returned that identifies the physical location of the computer
  1290. hardware. Examples of short names: "MIT AI Lab", "CMU-CSD". Examples of long
  1291. names:
  1292.  
  1293. "MIT Artificial Intelligence Laboratory"
  1294. "Massachusetts Institute of Technology
  1295. Artificial Intelligence Laboratory"
  1296. "Carnegie-Mellon University Computer Science Department"
  1297.  
  1298. See also user-homedir-pathname.
  1299.  
  1300. [Variable]
  1301. *features*
  1302.  
  1303. The value of the variable *features* should be a list of symbols that name
  1304. ``features'' provided by the implementation. Most such names will be
  1305. implementation-specific; typically a name for the implementation will be
  1306. included.
  1307.  
  1308. [old_change_begin]
  1309. One standard feature name is ieee-floating-point, which should be present if
  1310. and only if full IEEE proposed floating-point arithmetic [23] is supported.
  1311. [old_change_end]
  1312.  
  1313. The value of this variable is used by the #+ and #- reader syntax.
  1314.  
  1315. [change_begin]
  1316. X3J13 voted in March 1988 (SHARPSIGN-PLUS-MINUS-PACKAGE)   to specify that
  1317. feature names used with #+ and #- are read in the keyword package unless an
  1318. explicit prefix designating some other package appears. The standard feature
  1319. name ieee-floating-point is therefore actually the keyword
  1320. :ieee-floating-point, though one need not write the colon when using it with #+
  1321. or #-; thus #+ieee-floating-point and #+:ieee-floating-point mean the same
  1322. thing.
  1323. [change_end]
  1324.  
  1325. -------------------------------------------------------------------------------
  1326.  
  1327. 25.5. Identity Function
  1328.  
  1329. This function is occasionally useful as an argument to other functions that
  1330. require functions as arguments. (Got that?)
  1331.  
  1332. [Function]
  1333. identity object
  1334.  
  1335. The object is returned as the value of identity.
  1336.  
  1337. [change_begin]
  1338. The identity function is the default value for the :key argument to many
  1339. sequence functions (see chapter 14).
  1340.  
  1341. Table 12-1 illustrates the behavior in the complex plane of the identity
  1342. function regarded as a function of a complex numerical argument.
  1343.  
  1344. Many other constructs in Common Lisp have the behavior of identity when given a
  1345. single argument. For example, one might well use values in place of identity.
  1346. However, writing values of a single argument conventionally indicates that the
  1347. argument form might deliver multiple values and that the intent is to pass on
  1348. only the first of those values.
  1349.  
  1350. -------------------------------------------------------------------------------
  1351. Compatibility note: In Maclisp, progn was a function of any number of arguments
  1352. that returned its last argument, so progn could be used as an identity
  1353. function. In Common Lisp, progn is a special form and therefore cannot be used
  1354. for that purpose.
  1355. -------------------------------------------------------------------------------
  1356.  
  1357. [change_end]
  1358.  
  1359. -------------------------------------------------------------------------------
  1360.  
  1361.  
  1362.  
  1363.  
  1364.